<?
session_start();
include('templates/header.php');
$CLASS_APP = new app($mysqli);
$products = $CLASS_APP->get_products();
?>
    <input type="text" id="search_game" placeholder="Search game..." onkeyup="searchGame(this.value)">
    <h1>Games</h1>
    <div id="items">
        <?
        foreach ($products as $item) {
            ?>
            <!-- item -->
            <div style="background: url('<?= 'admin/' . $img_dir . $item["file"] ?>') no-repeat;" class="item">
                <div class="product-details">
                    <div class="title">
                        <a href="product/<?= toPermalink($item["product"]) ?>/<?= $item["id_products"] ?>/">
                            <h2><?= $item["product"] ?></h2></a>
                    </div>
                    <div class="price">
                        <strong><?= $item["price"] ?> €</strong>
                        <?
                        if ($CLASS_APP->check_product_stock($item["id_products"]) > 0) {
                            ?>
                            <button onclick="addItem(<?= $item["id_products"] ?>)" class="btn_buy">BUY</button><?
                        }else{
                            ?><button class="btn_buy nostock">NO STOCK</button><?
                        }
                        ?>
                    </div>
                </div>
            </div>
            <!-- end item-->
        <?
        }
        ?>
    </div>
<? include('templates/footer.php'); ?>